<template>
  <div class="hot-sale">
    <div class="header">{{ title }}</div>
    <div class="content">
      <div class="goods" v-for="goods in goodsList" :key="goods.id" @click="toGoodsDetailPageHandler(goods)">
        <img class="goods-image" :src="goods.image" />
        <div class="title">{{ goods.name }}</div>
        <div class="price">
          {{ goods.price }} <span class="iconfont icon-gouwuche"></span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    title: {
      type: String,
      default: ''
    },
    goodsList: {
      type: Array,
      default: () => []
    }
  },

  methods: {
    /**
     * 跳转到对应的商品详情页
     * @param { Object } goods 商品信息
     */
    toGoodsDetailPageHandler (goods) {
      this.$router.push(`/goods/detail/${goods.id}`)
    }
  }
}
</script>

<style lang="less" scoped>
@import "../../styles/variable.less";

.hot-sale {
  border: 1px solid @border-color2;
  margin-left: 40px;
  .header {
    background-color: @bg-grey;
    font-size: 18px;
    font-weight: 700;
    line-height: 41px;
    text-align: center;
  }
  .content {
    padding: 0px 20px;
    .goods {
      border-bottom: 1px solid @border-color2;
      margin-top: 24px;
      padding-bottom: 18px;
      .goods-image {
        width: 250px;
        height: 250px;
      }
      .title {
        margin-bottom: 8px;
        margin-top: 6px;
        text-align: center;
      }
      .price {
        color: @color-warning;
        font-size: 14px;
        text-align: center;
        .iconfont {
          background-color: @bg-color-golden-light;
          border-radius: 12px;
          color: @font-color-golden;
          cursor: pointer;
          display: inline-block;
          font-size: 13px;
          width: 24px;
          height: 24px;
          line-height: 25px;
          text-align: center;
          margin-left: 6px;
        }
      }
      &:last-child {
        border-bottom: 0px;
      }
    }
  }
}
</style>
